﻿//Write an expression that extracts from a given integer i the value of a given bit number b.
//Example: i=5; b=2 -> value=1.

using System;

class ExtractBitNumber
{
    static void Main()
    {
        Console.Write("Enter integer number: ");
        int integerNumber = int.Parse(Console.ReadLine());
        Console.Write("Enter position: ");
        int position = int.Parse(Console.ReadLine());

        int mask = 1 << position;
        int numberAndMask = integerNumber & mask;
        int bitValue = numberAndMask >> position;
        Console.WriteLine("i = {0}; b = {1} -> value = {2}", integerNumber, position, bitValue);
    }
}
